<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 创建10W个节点，添加到页面上
    // 方法一
    console.time("test1")
    for (var i = 0; i < 100000; i++) {
      var newDiv = document.createElement("div")
      document.body.appendChild(newDiv)
    }
    console.timeEnd("test1")

    // 方法二
    console.time("test2")
    var node = document.createElement("div")
    for (var i = 0; i < 100000; i++) {
      var newDiv = document.createElement("div")
      node.appendChild(newDiv)
    }
    document.body.appendChild(node)
    console.timeEnd("test2")
  </script>
</body>
</html>